var Guanfan = new Vue({

    el : '#GuifanHuizonglist',
    data :{

        deptId : '',
        renyuanleibie:'',
        jigoumingchengma:'',
        paixu:'jigoumingchengma',
        renyuan : {},
        jingshang:{},
        renyuanlist : [],
        renyuanleibielist:[],
        jingshangqingkuanglist:[],
        danweilist:[],


        editFlag : 0,					// 0:新增，1：修改
        show : false,					// 显示列表是否有数据
        jingshangqingkuang: false,

        pageIndex : 1,
        pageSize :6,
        pageCount : 0,
        recordCount : 0,
        inputPageIndexValue : "",


    },
    created : function() {

        this.findVaild(0);
        this.initDict();
        this.selectDeptAll();

    },
    methods : {

        // 绑定字典表
        initDict : function() {
            var _this = this;

            // 人员类别
            $.post("../dict_renyuanleibie/find_valid", {
                rdm : Math.random()
            }, function (ppData) {
                if (ppData != null) {
                    if (ppData.result == '1') {
                        var data = ppData.resultContent;
                        _this.renyuanleibielist = data;
                    } else {
                        layer.alert(ppData.message);
                    }
                }
            }, "json");
        },

        selectDeptAll : function() {
            var _this = this;

            // 单位
            $.post("../dept/findcengji_by_deptid", {
                deptid:"0",
                rdm : Math.random()
            }, function (ppData) {
                if (ppData != null) {
                    if (ppData.result == '1') {
                        var data = ppData.resultContent;
                        _this.danweilist = data;
                    } else {
                        layer.alert(ppData.message);
                    }
                }
            }, "json");
        },

        findVaild: function(ppFalg){
            var _this = this;
            if(ppFalg==1){
                _this.pageIndex = 1;
            }
            layer.open({type:3});
                $.post("../guifanluoshi_qingkuang/find_custom_by_deptid",{
                deptid : _this.deptId,
                renyuanleibie: _this.renyuanleibie,
                jigoumingchengma: _this.jigoumingchengma,
                paixu:_this.paixu,
                pageindex : _this.pageIndex,
                pagesize : _this.pageSize,
                rdm : Math.random()
            },function(ppData){
                layer.closeAll("loading");
                if (ppData != null){
                    if(ppData.result == "1"){
                        var data=ppData.resultContent;

                        var mmHtml = "<table class=\"table table-bordered\" style=\"margin-bottom:10px;overflow:hidden;\" v-if=\"show\" cellspacing=\"0\" cellpadding=\"0\">\n" +
                            "                    <tr style=\"font-weight: bold;\">\n" +
                            "                        <td style=\"text-align:center;vertical-align:middle;width: 40px;\" rowspan=\"3\">序号</td>\n" +
                            "                        <td style=\"text-align:center;vertical-align:middle;width: 700px; \" colspan=\"8\" >人员信息</td>\n" +
                            "                        <td style=\"text-align:center;vertical-align:middle;\" colspan=\"3\" >选择退出落实情况</td>\n" +
                            "                        <td style=\"text-align:center;vertical-align:middle;width: 40px;\" rowspan=\"3\">备注</td>\n" +
                            "                    </tr>\n" +
                            "                    <tr style=\"font-weight: bold;\">\n" +
                            "                        <td style=\"text-align:center;vertical-align:middle;\" colspan=\"6\">干部信息</td>\n" +
                            "                        <td style=\"text-align:center;vertical-align:middle;\" colspan=\"2\" >配偶、子女及其配偶信息</td>\n" +
                            "                        <td style=\"text-align:center;vertical-align:middle;width: 40px;\" colspan=\"2\">配偶、子女及其配偶退出经商办企业</td>\n" +
                            "                        <td style=\"text-align:center;vertical-align:middle;\" rowspan=\"2\">干部本人退出现职</td>\n" +
                            "                    </tr>\n" +
                            "                    <tr style=\"font-weight: bold;\">\n" +
                            "                        <td style=\"text-align:center;vertical-align:middle;width: 80px;\"  >姓名</td>\n" +
                            "                        <td style=\"text-align:center;vertical-align:middle;width: 80px;\"  >机构名称码</td>\n" +
                            "                        <td style=\"text-align:center;vertical-align:middle;width: 80px;\"  >部职别</td>\n" +
                            "                        <td style=\"text-align:center;vertical-align:middle;width: 80px;\"  >出生日期</td>\n" +
                            "                        <td style=\"text-align:center;vertical-align:middle;width: 100px;\"  >军衔等级及时间</td>\n" +
                            "                        <td style=\"text-align:center;vertical-align:middle;width: 100px;\"  >职务层级（等级）及时间</td>\n" +
                            "                        <td style=\"text-align:center;vertical-align:middle;width: 80px;\"  >姓名</td>\n" +
                            "                        <td style=\"text-align:center;vertical-align:middle;width: 100px;\" >与干部关系</td>\n" +
                            "                        <td style=\"text-align:center;vertical-align:middle;width: 200px;\"  >企业名称</td>\n" +
                            "                        <td style=\"text-align:center;vertical-align:middle;width: 200px;\"  >退出方式</td>\n" +
                            "                    </tr>";
                        if(data.RenyuanList.length > 0){
                            _this.show = true;
                            _this.renyuanlist=data.RenyuanList;

                            var PageInfo = data.PageInfo;
                            _this.pageIndex = PageInfo.pageIndex;
                            _this.recordCount = PageInfo.recordCount;
                            _this.pageCount = PageInfo.pageCount;

                            for (var i = 0; i < data.RenyuanList.length; i++) {
                                var mmRenyuan = data.RenyuanList[i];
                                var mmIndex = i+1;
                                var mmTruename = mmRenyuan.truename;
                                var mmJigoumingchengma = mmRenyuan.jigoumingchengma;
                                var mmBuzhibie = mmRenyuan.buzhibie;
                                var mmChusheng = mmRenyuan.chusheng2;
                                var mmJunxian = mmRenyuan.junxianleibietext+mmRenyuan.junxiandengjitext;
                                var mmJunxianshijian = "";
                                if (mmRenyuan.junxianshijian2!=undefined){
                                    mmJunxianshijian = mmRenyuan.junxianshijian2;
                                }
                                var mmZhiwucengji = mmRenyuan.zhiwucengjitext;
                                var mmZhiwushijian = mmRenyuan.zhiwushijian2;
                                var mmHebingshu = mmRenyuan.hebinghang;
                                var mmHebinghang ="";
                                if (mmHebingshu>1){
                                    mmHebinghang = "rowspan='"+mmHebingshu+"'";
                                }else{
                                    mmHebinghang = "";
                                }
                                var mmJiashuList = mmRenyuan.jiashuguifanlist;
                                mmHtml += "<tr>";
                                mmHtml += "<td style='text-align:center;vertical-align:middle;width: 40px;height: 100%'"+mmHebinghang+">"+mmIndex+"</td>";
                                mmHtml += "<td style='text-align:center;vertical-align:middle;width: 50px;height: 100%'"+mmHebinghang+">"+mmTruename+"</td>";
                                mmHtml += "<td style='text-align:center;vertical-align:middle;width: 80px;height: 100%'"+mmHebinghang+">"+mmJigoumingchengma+"</td>";
                                mmHtml += "<td style='text-align:center;vertical-align:middle;width: 80px;height: 100%'"+mmHebinghang+">"+mmBuzhibie+"</td>";
                                // mmHtml += "<td style='text-align:center;vertical-align:middle;width: 50px;height: 100%'"+mmHebinghang+">"+mmRenyuanleibie+"</td>";
                                mmHtml += "<td style='text-align:center;vertical-align:middle;width: 50px;height: 100%' "+mmHebinghang+">"+mmChusheng+"</td>";
                                mmHtml += "<td style='text-align:center;vertical-align:middle;width: 60px;height: 100%' "+mmHebinghang+"><div>"+mmJunxian+"</div><div>"+mmJunxianshijian+"</div></td>";
                                mmHtml += "<td style='text-align:center;vertical-align:middle;width: 100px;height: 100%'"+mmHebinghang+"><div>"+mmZhiwucengji+"</div><div>"+mmZhiwushijian+"</div></td>";

                                if (mmJiashuList.length==0){
                                    mmHtml += "<td colspan='6'></td></tr>";
                                }
                                for (var j = 0; j < mmJiashuList.length; j++) {
                                    var mmJiashu = mmJiashuList[j];
                                    var mmXingming = mmJiashu.name;
                                    var mmGuanxi = mmJiashu.guanxitext;
                                    var mmHebingshu2 = mmJiashu.hebinghang;
                                    var mmzhenbieList = mmJiashu.zhenbielist;
                                    var mmHebinghang2 ="";
                                    if (mmHebingshu2>1){
                                        mmHebinghang2 = "rowspan='"+mmHebingshu2+"'";
                                    }else{
                                        mmHebinghang2 ="";
                                    }

                                    var mmHuanhangfu = "";
                                    if(j!=0){
                                        mmHuanhangfu = "<tr>";
                                    }
                                    mmHtml += mmHuanhangfu+"<td style='text-align:center;vertical-align:middle;width: 49px;height: 100%'"+mmHebinghang2+">"+mmXingming+"</td>";
                                    mmHtml += "<td style='text-align:center;vertical-align:middle;width: 50px;height: 100%'"+mmHebinghang2+">"+mmGuanxi+"</td>";


                                    if (mmzhenbieList.length==0){
                                        mmHtml += "<td colspan='4'></td></tr>";
                                    }
                                    for (var k = 0; k < mmzhenbieList.length; k++) {
                                        var mmJingshang = mmzhenbieList[k];
                                        var mmQiyename=mmJingshang.qiyename;
                                        var BENRENTUICHU =mmJingshang.benrentuichu ==null?"":mmJingshang.benrentuichu ; // 本人退出
                                        var TUICHUJINGSHANG = mmJingshang.tuichujingshang ==null?"":mmJingshang.tuichujingshang ; // 退出经商办企业
                                        var BEIZHU =mmJingshang.beizhu ==null?"":mmJingshang.beizhu ; // 备注

                                        var mmHuanhangfu2 = "";
                                        if (k!=0){
                                            mmHuanhangfu2 = "<tr>";
                                        }
                                        var arr=TUICHUJINGSHANG.split(',');
                                        var TUICHUJINGSHANGText="";
                                        if(arr.indexOf('A')!=-1){
                                            TUICHUJINGSHANGText="注销，";
                                        }
                                        if(arr.indexOf('B')!=-1){
                                            TUICHUJINGSHANGText+="转让股权（财产份额），";
                                        }
                                        if(arr.indexOf('C')!=-1){
                                            TUICHUJINGSHANGText+="变更经营范围，";
                                        }
                                        if(arr.indexOf('D')!=-1){
                                            TUICHUJINGSHANGText+="调整岗位、不再担任高级职务，";
                                        }
                                        if(arr.indexOf('E')!=-1){
                                            TUICHUJINGSHANGText+="辞职，";
                                        }
                                        if(arr.indexOf('F')!=-1){
                                            TUICHUJINGSHANGText+="其他，";
                                        }
                                        TUICHUJINGSHANGText=TUICHUJINGSHANGText.slice(0,TUICHUJINGSHANGText.length-1);

                                        if(BENRENTUICHU=="1"){
                                            BENRENTUICHU="岗位调整";
                                        }
                                        if(BENRENTUICHU=="2"){
                                            BENRENTUICHU="退役";
                                        }
                                        if(BENRENTUICHU=="3"){
                                            BENRENTUICHU="辞职";
                                        }
                                        if(BENRENTUICHU=="4"){
                                            BENRENTUICHU="解除聘用";
                                        }


                                        mmHtml += "<td style='text-align:center;vertical-align:middle;width: 50px;height: 100%'>"+mmQiyename+"</td>";
                                        mmHtml += "<td style='text-align:center;vertical-align:middle;width: 50px;height: 100%'>"+TUICHUJINGSHANGText+"</td>";
                                        mmHtml += "<td style='text-align:center;vertical-align:middle;width: 50px;height: 100%'>"+BENRENTUICHU+"</td>";
                                        mmHtml += "<td style='text-align:center;vertical-align:middle;width: 50px;height: 100%'>"+BEIZHU +"</td></tr>";

                                    }


                                }

                            }


                        }else {
                            _this.show = false;
                        }
                        mmHtml += "</table>";
                        $("#List").html(mmHtml);
                    }else{
                        layer.alert(ppData.message);
                    }
                }

            },"json");
        },


        Daochu: function(){
            var _this = this;
            window.open("../daochu/guifanhuizong?deptid="+_this.deptId+"&renyuanleibie="+_this.renyuanleibie+"&jigoumingchengma="+_this.jigoumingchengma+"&paixu="+_this.paixu);
        },

        //跳到首页
        SetPageIndex : function(){
            this.pageIndex = 1;
        },
        SetPageEnd : function(){
            this.pageIndex = this.pageCount;
        },
        //上一页
        SetPageIndexPrePage : function(){
            var PrePage = ((this.pageIndex -1) <= 0) ? 1 : (this.pageIndex -1);
            this.pageIndex = PrePage;
        },
        //下一页
        SetPageIndexNextPage : function(){
            var NextPage = ((this.pageIndex +1) >= this.pageCount) ? this.pageCount : (this.pageIndex +1);
            this.pageIndex = NextPage;
        },
        //跳转界面
        JumpPage : function(){
            if(this.inputPageIndexValue <= 1){
                this.inputPageIndexValue = 1;
            }else if(this.inputPageIndexValue >= this.pageCount){
                this.inputPageIndexValue = this.pageCount;
            }
            this.pageIndex = this.inputPageIndexValue;
            this.inputPageIndexValue = '';
        },




    },
    watch :{
        //监控分页情况，刷新列表
        pageIndex : function(){

            this.findVaild(0);
        }
    }

});
